<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>编辑入院咨询</title>
    <link rel="stylesheet" href="${params.contextPath}/static/plug/layui/css/layui.css">
	<#include "/common/resource.ftl">
	<script type="text/javascript">
		$(function () {
            $.ajaxRequest({
                url: '${params.contextPath}/web/dictionary/queryAcceptList',
                data: {dictionaryName: "sex"},
                success: function (data) {
                    if (!data.success) {
                        $.message(data.message);
                        return;
                    }
                    var sexStr = "";
                    var record = data.data;
                    for (var i = 0; i < record.length; i++) {
                        sexStr += "<option value="+ record[i].value +">"+ record[i].name +"</option>";
                    }
                    $("#sex").append(sexStr);
                    layui.form.render();
                }
            });
			<#if (params.id)??>
				$.ajaxRequest({
					url: '${params.contextPath}/web/hospitalConsult/query',
					data: {id: "${params.id}"},
					success: function (data) {
						if (!data.success) {
							$.message(data.message);
							return;
						}
						var record = data.data;
						for (var key in record) {
							$("[name='" + key + "']").val(record[key]);
						}
						layui.form.render();
					}
				});
			</#if>
            $(".ajax-form").unbind().submit(function () {
                try {
                    var form = $(this);
                    if (!form.valid()) {
                        $.message("验证不通过，无法提交表单");
                        return false;
                    }

                    form.formSubmit({
                        callBack:function (data) {
                            <#if (params.tag)??>
                            history.go(-1);
                            </#if>
                        }
                    });
                } catch (e) {
                    console.log("表单提交错误：" + e);
                }
                return false;
            });
		});
	</script>
    <style>
        .layui-form-label{width:95px;}
        .layui-input-block{margin-left:125px;}
        .layui-card-header{font-weight:bold;}
        .layui-form select {display:none !important;}
    </style>
</head>
<body>
	<div class="ui-form">
		<form class="layui-form ajax-form" action="${params.contextPath}/web/hospitalConsult/<#if (params.id)??>modify<#else>save</#if>" method="post">
			<input type="hidden" name="id" value="${params.id}" />
			<div class="layui-form-item">
                <label class="layui-form-label">咨询者<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <input type="text" name="consultName" placeholder="请输入咨询者" class="layui-input {required:true}"/>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">与入院者关系<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <input type="text" name="relationship" placeholder="请输入与入院者关系" class="layui-input {required:true}"/>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">入院者<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <input type="text" name="elderName" placeholder="请输入入院者" class="layui-input {required:true}"/>
                </div>
            </div>
            <#if (params.tag)??>
                <div class="layui-form-item">
                    <label class="layui-form-label">性别<span class="ui-request">*</span></label>
                    <div class="layui-input-block">
                        <select id="sex" name="sex" class="layui-input {required:true}" lay-search>

                        </select>
                    </div>
                </div>
                <#else>
                <div class="layui-form-item">
                    <label class="layui-form-label">性别<span class="ui-request">*</span></label>
                    <div class="layui-input-block">
                        <select name="sex" dic-code="sex" class="layui-input dic-select {required:true}"></select>
                    </div>
                </div>
            </#if>
			<div class="layui-form-item">
                <label class="layui-form-label">年龄<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <input type="text" name="age" placeholder="请输入年龄" class="layui-input {required:true}"/>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">收入</label>
                <div class="layui-input-block">
                    <input type="text" name="income" placeholder="请输入收入" class="layui-input"/>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">医保</label>
                <div class="layui-input-block">
                    <input type="text" name="medical" placeholder="请输入医保" class="layui-input"/>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">户籍<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <input type="text" name="household" placeholder="请输入户籍" class="layui-input {required:true}"/>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">现居住地址<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <input type="text" name="address" placeholder="请输入现居住地址" class="layui-input {required:true}"/>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">联系电话<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <input type="text" name="phone" placeholder="请输入联系电话" class="layui-input {required:true}"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">身体状况<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <textarea type="text" name="health" class="layui-textarea {required:true}" maxlength="500"></textarea>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">入院要求<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <textarea type="text" name="remark" class="layui-textarea {required:true}" maxlength="500"></textarea>
                </div>
            </div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="submit" value="保存" class="layui-btn" />
				</div>
			</div>
		</form>
	</div>
</body>

</html>
